package com.qfedu.wfxvip.service.impl;

import com.qfedu.wfxvip.mapper.GoodsMapper;
import com.qfedu.wfxvip.po.WxbGood;
import com.qfedu.wfxvip.po.WxbGoodSku;
import com.qfedu.wfxvip.service.IgoodService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service
public class GoodServiceImpl implements IgoodService{
    @Resource
    private GoodsMapper goodsMapper;
    @Override
    public List<WxbGood> queryAllGoods() {
        List<WxbGood> wxbGoods = goodsMapper.queryAllGoods();
        return wxbGoods;
    }

    @Transactional(readOnly = true)
    public WxbGood queryGoodsById(String goodId) {
        WxbGood wxbGood = goodsMapper.queryGoodsById(goodId);
        List<WxbGoodSku> wxbGoodSkus = querySkuListByGoodId(goodId);
        wxbGood.setSkuList(wxbGoodSkus);
        return wxbGood;
    }

    @Transactional(readOnly = true)
    public List<WxbGoodSku> querySkuListByGoodId(String goodId) {
        List<WxbGoodSku> wxbGoodSkus = goodsMapper.querySkuListByGoodId(goodId);
        return wxbGoodSkus;
    }
}
